/**
 * @file polygon.h
 * @see http://code.google.com/p/mega8-hob/source/browse/trunk/polygon.h
 * @author Hamish Cumming & Brian Thorne
 * @version see SVN revision number
 */
#ifndef polygon_h
#define polygon_h
 
#define PI 3.14159 
#include "paver.h"
#include <stdlib.h>
#include "linked_list.h"
/* linear tolerances for position calculations in mm */ 
#define L_TOL 1 //for clickage
#define L_TOL2 0.2 //for parallelism 

typedef struct /* Line segment */
{
    point_t start; /* start of line segment */
    point_t end; /* end of line segment */
} segment_t; /* start must not = end */

typedef struct /* Line */
{
    float a; /* coefficient for x */
    float b; /* coefficient for y */
    float c; /* ax + by + c = 0 for points on line */
} line_t;

/* Prototypes */
line_t line_from_seg (segment_t segment);
int between (point_t start, point_t end, point_t point);
float distance_from_line (line_t line, point_t point);
int segments_intersect (segment_t seg1, segment_t seg2);
int pnt_on_seg(segment_t segment, point_t point);
int pnt_on_pgon (linked_list_t* polygon, point_t point);
float seg_angle_subtended (segment_t segment, point_t point);
int pnt_outside_pgon (linked_list_t* polygon, point_t point);
segment_t pnt_on_pgon_segment(linked_list_t * polygon, point_t point);
int pgon_close(linked_list_t * polygon);
int pnt_intersects_pgon(linked_list_t * polygon, point_t point);

#endif
